<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="http://static.xiaomo.info/jquery.js"></script>
</head>
<body onload="onLoadAjax()">
<div id="result"></div>
<script>
    function onLoadAjax() {
        var name = getQueryString("email");
        var password = getQueryString("password");
        var validateCode = getQueryString("validateCode");
        var time = getQueryString("time");
        $.ajax({
            type: "POST",
            url: "http://192.168.1.165:8080/user/validateEmail",
            data: {email: name, password: password, validateCode: validateCode, time: time},
            success: function (data) {
                if (data.resultCode != 0) {
                    $("#result").html(getResult(data.resultCode));
                } else {
                    $("#result").html("验证成功，请登录！");
                }

            },
            error: function (error) {
                $("#result").html("验证失败，请不要重复提交！");
            }
        });
    }

    /**
     * 获取url参数
     * @param name
     * @returns {string}
     */
    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]);
        return "";
    }


    function getResult (resultCode) {
        switch (resultCode) {
            case 1:
                return "时间过期";
            case 2:
                return "找不到此用户";
            case 3:
                return "用户名重复";
            default:
                console.log("出现新类型：" + resultCode);
                return "未知错误";
        }
    }


</script>
</body>
</html>